package com.woniuxy.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: Online-education-examination-platform-back
 * @BelongsPackage: com.woniuxy.util
 * @Author: Banol Zi
 * @CreateTime: 2022-06-10  16:31
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
public class PaperJSONToRedis {

    private static final String EXAM_KEY = "key_exam";

    private static final String EXAM_ITEM_PAPER_JSON = "exam_key_json";

    private static final long EXPIRE_TIME = 100000l;

    private static final long SCAN_TIME = 100000l;

    @Autowired
    RedisUtil redisUtil;

    public Integer test(){
        redisUtil.hset("key","item2","exam_json");
        return 1;
    }

    public Integer putToRedis(){
        redisUtil.hset("key","item2","exam_json");
        return 1;
    }

    public String putToRedis(Integer itemId, String exam_json) {
        String item = EXAM_ITEM_PAPER_JSON.concat(":" + itemId.toString());
        redisUtil.hset(EXAM_KEY, item, exam_json);
        return item;
    }

    public String getFromRedis(Integer id){
        String value = (String) redisUtil.hget(EXAM_KEY,EXAM_ITEM_PAPER_JSON.concat(":" + id));
        return value;
    }
}
